#include "stdafx.h"
#ifdef LIT_OGRE_SUPPORT
#include "LitPhysicsBodyState.h"
#include "LitPhysicsBody.h"

namespace Lit
{
	namespace Physics
	{
		BodyState::BodyState( ){}
		BodyState::BodyState( const BodyState& rk )
		{
			mInertia = rk.mInertia;
			mTransformation = rk.mTransformation;
			mForces = rk.mForces;
			mSaved = rk.mSaved;
		}
		BodyState::~BodyState( ){}

		void BodyState::saveState( const Body * body ){
			mInertia = InertialMatrix( body->getMassMatrix(), body->getCenterOfMass() );
			mTransformation = Matrix( body->getEntity()->getPosition(), body->getEntity()->getOrientation() );
			mSaved = true;
		}
		void BodyState::restoreState( Body * body ){
			if( !mSaved ) return;
			body->setInertia( mInertia );
			body->setMatrix( mTransformation );
			mSaved = false;
		}
	};
};

#endif